package com.ruoyi.amuse.PostBarManger.controller;


import com.ruoyi.amuse.PostBarManger.domain.PostBarManger;
import com.ruoyi.amuse.PostBarManger.service.IPostBarMangerService;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 学校动态管理Controller
 * 
 * @author juwujie
 * @date 2024-07-26
 */
@RestController
@RequestMapping("/PostBarManger/PostBarManger")
public class PostBarMangerController extends BaseController
{
    @Autowired
    private IPostBarMangerService postBarMangerService;

    /**
     * 查询学校动态管理列表
     */
    @RequiresPermissions("PostBarManger:PostBarManger:list")
    @GetMapping("/list")
    public TableDataInfo list(PostBarManger postBarManger)
    {
        startPage();
        List<PostBarManger> list = postBarMangerService.selectPostBarMangerList(postBarManger);
        return getDataTable(list);
    }

    /**
     * 导出学校动态管理列表
     */
    @RequiresPermissions("PostBarManger:PostBarManger:export")
    @Log(title = "学校动态管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PostBarManger postBarManger)
    {
        List<PostBarManger> list = postBarMangerService.selectPostBarMangerList(postBarManger);
        ExcelUtil<PostBarManger> util = new ExcelUtil<PostBarManger>(PostBarManger.class);
        util.exportExcel(response, list, "学校动态管理数据");
    }

    /**
     * 获取学校动态管理详细信息
     */
    @RequiresPermissions("PostBarManger:PostBarManger:query")
    @GetMapping(value = "/{postId}")
    public AjaxResult getInfo(@PathVariable("postId") Long postId)
    {
        return success(postBarMangerService.selectPostBarMangerByPostId(postId));
    }

    /**
     * 新增学校动态管理
     */
    @RequiresPermissions("PostBarManger:PostBarManger:add")
    @Log(title = "学校动态管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PostBarManger postBarManger)
    {
        return toAjax(postBarMangerService.insertPostBarManger(postBarManger));
    }

    /**
     * 修改学校动态管理
     */
    @RequiresPermissions("PostBarManger:PostBarManger:edit")
    @Log(title = "学校动态管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PostBarManger postBarManger)
    {
        return toAjax(postBarMangerService.updatePostBarManger(postBarManger));
    }

    /**
     * 删除学校动态管理
     */
    @RequiresPermissions("PostBarManger:PostBarManger:remove")
    @Log(title = "学校动态管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{postIds}")
    public AjaxResult remove(@PathVariable Long[] postIds)
    {
        return toAjax(postBarMangerService.deletePostBarMangerByPostIds(postIds));
    }
}
